MIPS Instruction Set 您所在的位置:网站首页 instruction into MIPS Instruction Set

MIPS Instruction Set

2024-05-15 18:50| 来源: 网络整理| 查看: 265

This is a **partial list** of the available MIPS32 instructions, system calls, and assembler directives. For more MIPS instructions, refer to the Assembly Programming section on the class聽Resources page.

In all examples, $1, $2, $3 represent registers. For class, you should use the register names, not the corresponding register numbers.

Arithmetic Instructions InstructionExampleMeaningComments add add $1,$2,$3 $1=$2+$3 subtract sub $1,$2,$3 $1=$2-$3 add immediate addi $1,$2,100 $1=$2+100 "Immediate" means a constant number add unsigned addu $1,$2,$3 $1=$2+$3 Values are treated as unsigned integers, not two's complement integers subtract unsigned subu $1,$2,$3 $1=$2-$3 Values are treated as unsigned integers,not two's complement integers add immediate unsigned addiu $1,$2,100 $1=$2+100 Values are treated as unsigned integers,not two's complement integers Multiply (without overflow) mul $1,$2,$3 $1=$2*$3 Result is only 32 bits! Multiply mult $2,$3 $hi,$low=$2*$3 Upper 32 bits stored in special register hiLower 32 bits stored in special register lo Divide div $2,$3 $hi,$low=$2/$3 Remainder stored in special register hiQuotient stored in special register lo Unsigned Divide divu $2,$3 $hi,$low=$2/$3

$2 and $3 store unsigned values.

Remainder stored in special register hiQuotient stored in special register lo

Logical InstructionExampleMeaningComments and and $1,$2,$3 $1=$2&$3 Bitwise AND or or $1,$2,$3 $1=$2|$3 Bitwise OR and immediate andi $1,$2,100 $1=$2&100 Bitwise AND with immediate value or immediate or $1,$2,100 $1=$2|100 Bitwise OR with immediate value shift left logical sll $1,$2,10 $1=$210 Shift right by constant number of bits

Data Transfer InstructionExampleMeaningComments load word lw $1,100($2) $1=Memory[$2+100] Copy from memory to register store word sw $1,100($2) Memory[$2+100]=$1 Copy from register to memory load upper immediate lui $1,100 $1=100x2^16 Load constant into upper 16 bits.聽Lower 16 bits are set to zero. load address la $1,label $1=Address of label Pseudo-instruction (provided by assembler, not processor!)Loads computed address of label (not its contents) into register load immediate li $1,100 $1=100 Pseudo-instruction (provided by assembler, not processor!)Loads immediate value into register move from hi mfhi $2 $2=hi Copy from special register hi to general register move from lo mflo $2 $2=lo Copy from special register lo to general register move move $1,$2 $1=$2 Pseudo-instruction (provided by assembler, not processor!)Copy from register to register.

Variations on load and store also exist for smaller data sizes:

16-bit halfword: lh and sh 8-bit byte: lb and sb

Conditional Branch

All conditional branch instructions compare the values in two registers together. If the comparison test is true, the branch is taken (i.e. the processor jumps to the new location). Otherwise, the processor continues on to the next instruction.

InstructionExampleMeaningComments branch on equal beq $1,$2,100 if($1==$2) go to PC+4+100 Test if registers are equal branch on not equal bne $1,$2,100 if($1!=$2) go to PC+4+100 Test if registers are not equal branch on greater than bgt $1,$2,100 if($1>$2) go to PC+4+100 Pseduo-instruction branch on greater than or equal bge $1,$2,100 if($1>=$2) go to PC+4+100 Pseduo-instruction branch on less than blt $1,$2,100 if($1


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有